home *** CD-ROM | disk | FTP | other *** search
Gui4CLI script | 1999-11-26 | 6.1 KB | 273 lines |
- G4C
-
- ; Rep.gc 1.4 (by D.Kelesekis)
- ; =================================================================
-
- ; This is a GUI script for the "Rep" command, which replaces strings
- ; in text files.
-
- ; =================================================================
-
- ; The window & graphics
-
- ; =================================================================
-
- WINBIG 98 11 412 179 'Replace - SYS:'
- WinType 11110001 ; it's resizable & font sensitive with all gadgets
- resinfo 8 640 256
-
- BOX 0 0 0 0 OUT button
-
- XTEXTBOX 208 20 195 77 '' ''
- attr tbox 2/1/3/button/in
- attr resize 1010
-
- XTEXTBOX 208 100 196 34 '' ''
- attr tbox 2/1/3/button/in
- attr resize 1010
-
- ; =================================================================
-
- ; System events
-
- ; =================================================================
-
- xOnLoad
- from = ""
- to = ""
- todir = ram:
- savetodir = ON
- ci = ""
- guiopen rep.gc
- ifexists file c:rep
- RUN 'resident c:Rep pure add'
- elseifexists file guis:c/rep
- RUN 'resident guis:c/Rep pure add'
- else
- extract rep.gc guipath path
- joinfile $path rep path
- ifexists file $path
- RUN 'resident $path pure add'
- else
- ezreq 'REP was not found!' OK ''
- endif
- endif
- ; helper gui
- ifexists file guis:tools/rtn/filepop
- helper = 1 ; set flag to know we have it
- else
- helper = 0
- endif
-
-
- xOnClose
- guiquit rep.gc
- run 'resident rep remove'
-
- ; =================================================================
-
- ; The Directory listview
-
- ; =================================================================
-
- XLISTVIEW 4 4 199 170 "" file SYS: 10 DIR
- GadID 1
- attr resize 0012
- gadhelp 'Select files to act upon'
- GadFont #mono 8 000
- if $helper = 1
- guiload guis:tools/rtn/filepop $rep.gc/file
- endif
-
- xlvdirhook 1
- setwintitle rep.gc '$$lv.dir'
-
-
- ; =================================================================
-
- ; The listview's buttons
-
- ; =================================================================
-
- XBUTTON 208 4 30 14 P
- gadhelp 'CD to Parent dir'
- attr resize 1010
- lvuse rep.gc 1
- lvdir parent
- setwintitle rep.gc '$$lv.dir'
-
- XBUTTON 240 4 30 14 D
- gadhelp 'Show Device list'
- attr resize 1010
- lvuse rep.gc 1
- lvdir disks
- setwintitle rep.gc '$$lv.dir'
-
- XBUTTON 276 4 30 14 A
- gadhelp 'Select all items'
- attr resize 1010
- lvuse rep.gc 1
- lvdir all
-
- XBUTTON 308 4 30 14 N
- gadhelp 'Unselect all items'
- attr resize 1010
- lvuse rep.gc 1
- lvdir none
-
-
- ; =================================================================
-
- ; Settings - xTEXTIN & xCYCLER gadgets
-
- ; =================================================================
-
- XTEXTIN 216 36 180 15 '' from "" 100 ; string to Rep
- gadhelp 'Enter string to search for and replace'
- attr resize 1010
- attr title 2/1/shadow/left/above/String:
- gadid 30
- setgad rep.gc 31 on ; goto next gadget
-
- XTEXTIN 216 64 180 15 '' to "" 100 ; Rep with this
- gadhelp 'Enter string with which to replace the above'
- attr resize 1010
- attr title "2/1/shadow/left/above/To string:"
- gadid 31
- setgad rep.gc 30 on
-
- XCYCLER 216 80 180 14 "" ci
- gadhelp 'Search mode'
- attr resize 1010
- cstr "Case Sensitive" ""
- cstr "Case Insensitive" I
-
-
- ; =================================================================
-
- ; Save to a different dir
-
- ; =================================================================
- ; --- Dir to save file in. If this is the same dir as the file being
- ; --- converted, then the file will be overwriten.
-
- XCHECKBOX 368 104 26 11 "" savetodir ON OFF ON
- gadhelp 'Check to copy altered files to other dir - Requester will open..'
- attr resize 1010
- if $savetodir == ON
- setgad rep.gc 20 on
- ReqFile -1 -1 300 200 "Choose destination:" DIR todir ram:
- update rep.gc 20 $todir
- else
- setgad rep.gc 20 off
- endif
-
- XTEXTIN 216 116 180 15 '' todir "Ram:" 100
- gadhelp 'Altered files will be saved in this dir'
- attr title "2/1/shadow/left/above/Save to dir:"
- attr resize 1010
- gadid 20
-
-
- ; =================================================================
-
- ; Do it.
-
- ; =================================================================
-
- TEXT 208 144 196 14 "Waiting.." 50 BOX ; show stuff here..
- attr resize 1210
- gadid 2
-
- XBUTTON 208 160 96 14 Start
- gadhelp 'Start replacing'
- attr resize 1210
- gadid 100
-
- ; --- check that we have all the parameters we need
- lvuse rep.gc 1
- lvmulti first
- if $file = ""
- update rep.gc 2 "No file chosen."
- stop
- endif
- if $from = ""
- update rep.gc 2 'No "From" defined!'
- stop
- endif
- if $to = ""
- update rep.gc 2 'No "To" defined!'
- stop
- endif
-
- ; --- get dest dir, if defined, and make dest name..
- destfile = ""
- if $savetodir == ON
- and $todir > " "
- extract file FILE fname
- dest = $todir
- joinfile $dest $fname destfile
- endif
- update rep.gc 2 '$file'
-
- ; --- launch it..
- setgad rep.gc 100 off
- flag = 0
- launch 5 'Rep $file $from $to $destfile $ci'
-
-
- ; --- Use of the launch command will allow the other GUIs running on
- ; --- this instance of Gui4Cli to go about their business normally
- ; --- Then when this file is finished ...
-
- xOnReturn 5
- ; --- note our arrival..
- update rep.gc 2 'OK - $file'
- lvuse rep.gc 1
- lvmulti OFF
-
- ; --- check if we've already been told to stop..
- if $flag != 0
- setgad rep.gc 100 on
- stop
- endif
-
- ; --- do next file
- lvmulti next
- if $file = "" ; no more files
- if $todir > " "
- lvdir #$todir
- setwintitle rep.gc '$$lv.dir'
- else
- lvdir refresh
- endif
- setgad rep.gc 100 on
- stop
- endif
- if $savetodir == ON
- and $todir > " "
- extract file FILE fname
- dest = $todir
- joinfile $dest $fname destfile
- endif
- update rep.gc 2 '$file'
- launch 5 'Rep $file $from $to $destfile $ci'
-
-
- ; =================================================================
-
- ; Cancel & text display
-
- ; =================================================================
-
- XBUTTON 308 160 96 14 Stop
- gadhelp 'Abort replacing'
- attr resize 1210
- breaktask Rep C
- setvar flag 1
-
- xonfail ; everybody's human..
- setgad rep.gc 100 on
- update rep.gc 2 '** Error **'
-
-